package model.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.entity.stats.Stat;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.item.EquipmentSlot;
import model.item.EquipmentType;
import model.item.EquippableItem;
import model.item.OneShotItem;
import model.item.TakeableItem;
import model.skill.ActivateableSkill;
import model.skill.Bane;
import model.skill.BindWounds;
import model.skill.Boon;
import model.skill.Brawl;
import model.skill.DetectTrap;
import model.skill.Enchantment;
import model.skill.NonactivateableSkill;
import model.skill.Observation;
import model.skill.OneHandedWeapon;
import model.skill.ProjectileLibrary;
import model.skill.Ranged;
import model.skill.Skill;
import model.skill.Staff;
import model.skill.TwoHandedWeapon;

public class OccupationLibrary {

	static private OccupationLibrary instance = null;
	
	private static Map<String, Occupation> occupations;
	
	private OccupationLibrary()
	{
		occupations = new HashMap<String, Occupation>();
		initLibrary();
	}
	
	public static OccupationLibrary getInstance() {
		if ( instance != null ) {
			return instance;
		}
		return instance = new OccupationLibrary();
	}
	
	public void initLibrary()
	{
		StatSet smasherStats = new StatSet();
		StatSet summonerStats = new StatSet();
		StatSet sneakStats = new StatSet();
		
		Stat healthStat = new Stat(100, StatType.HP);
		Stat manaStat = new Stat(100, StatType.MP);
		Stat speedStat = new Stat(.05, StatType.MOVEMENTSPEED);
		Stat agilityStat = new Stat(10, StatType.AGILITY);
		Stat strengthStat = new Stat(10, StatType.STRENGTH);
		Stat intellectStat = new Stat(10, StatType.INTELLECT);
		Stat hardinessStat = new Stat(10, StatType.HARDINESS);
		
		Stat improvedAgilityStat = new Stat(15, StatType.AGILITY);
		Stat improvedStrengthStat = new Stat(15, StatType.STRENGTH);
		Stat improvedIntellectStat = new Stat(15, StatType.INTELLECT);
		
		smasherStats.addStat(StatType.HP, healthStat);
		smasherStats.addStat(StatType.MP, manaStat);
		smasherStats.addStat(StatType.MOVEMENTSPEED, speedStat);
		smasherStats.addStat(StatType.AGILITY, agilityStat);
		smasherStats.addStat(StatType.STRENGTH, improvedStrengthStat);
		smasherStats.addStat(StatType.INTELLECT, intellectStat);
		smasherStats.addStat(StatType.HARDINESS, hardinessStat);
		
  		summonerStats.addStat(StatType.HP, healthStat);
		summonerStats.addStat(StatType.MP, manaStat);
		summonerStats.addStat(StatType.MOVEMENTSPEED, speedStat);
		summonerStats.addStat(StatType.AGILITY, agilityStat);
		summonerStats.addStat(StatType.STRENGTH, strengthStat);
		summonerStats.addStat(StatType.INTELLECT, improvedIntellectStat);
		summonerStats.addStat(StatType.HARDINESS, hardinessStat);
		
  		sneakStats.addStat(StatType.HP, healthStat);
		sneakStats.addStat(StatType.MP, manaStat);
		sneakStats.addStat(StatType.MOVEMENTSPEED, speedStat);
		sneakStats.addStat(StatType.AGILITY, improvedAgilityStat);
		sneakStats.addStat(StatType.STRENGTH, strengthStat);
		sneakStats.addStat(StatType.INTELLECT, intellectStat);
		sneakStats.addStat(StatType.HARDINESS, hardinessStat);
		
		List<String> smasherEquipmentTypes = new ArrayList<String>();
		List<String> summonerEquipmentTypes = new ArrayList<String>();
		List<String> sneakEquipmentTypes = new ArrayList<String>();
		
		smasherEquipmentTypes.add(EquipmentType.TWOHANDED);
		smasherEquipmentTypes.add(EquipmentType.ONEHANDED);
		smasherEquipmentTypes.add(EquipmentType.RANGED);
		smasherEquipmentTypes.add(EquipmentType.STAFF);
		smasherEquipmentTypes.add(EquipmentType.BRAWLING);
		
		summonerEquipmentTypes.add(EquipmentType.ONEHANDED);
		summonerEquipmentTypes.add(EquipmentType.STAFF);
		
		sneakEquipmentTypes.add(EquipmentType.ONEHANDED);
		sneakEquipmentTypes.add(EquipmentType.RANGED);
		
		List<Skill> smasherAllowableSkills = new ArrayList<Skill>();
		List<Skill> summonerAllowableSkills = new ArrayList<Skill>();
		List<Skill> sneakAllowableSkills = new ArrayList<Skill>();
		
		smasherAllowableSkills.add(new BindWounds());
		smasherAllowableSkills.add(new Observation());
		smasherAllowableSkills.add(new OneHandedWeapon());
		smasherAllowableSkills.add(new TwoHandedWeapon());
		smasherAllowableSkills.add(new Brawl());
		
		summonerAllowableSkills.add(new BindWounds());
		summonerAllowableSkills.add(new Observation());
		summonerAllowableSkills.add(new Enchantment());
		summonerAllowableSkills.add(new Boon());
		summonerAllowableSkills.add(new Bane());
		summonerAllowableSkills.add(new Staff());
		
		sneakAllowableSkills.add(new BindWounds());
		sneakAllowableSkills.add(new Observation());
		sneakAllowableSkills.add(new DetectTrap());
		sneakAllowableSkills.add(new Ranged());
		
		List<ActivateableSkill> smasherActivateableSkills = new ArrayList<ActivateableSkill>();
		List<ActivateableSkill> summonerActivateableSkills = new ArrayList<ActivateableSkill>();
		List<ActivateableSkill> sneakActivateableSkills = new ArrayList<ActivateableSkill>();
		
		smasherActivateableSkills.add(new BindWounds());
		smasherActivateableSkills.add(new OneHandedWeapon());
		smasherActivateableSkills.add(new TwoHandedWeapon());
		smasherActivateableSkills.add(new Brawl());
		
		summonerActivateableSkills.add(new BindWounds());
		summonerActivateableSkills.add(new Enchantment());
		summonerActivateableSkills.add(new Boon());
		summonerActivateableSkills.add(new Bane());
		summonerActivateableSkills.add(new Staff());
		
		sneakActivateableSkills.add(new BindWounds());
		sneakActivateableSkills.add(new Ranged());
		
		List<NonactivateableSkill> smasherNonActivateableSkills = new ArrayList<NonactivateableSkill>();
		List<NonactivateableSkill> summonerNonActivateableSkills = new ArrayList<NonactivateableSkill>();
		List<NonactivateableSkill> sneakNonActivateableSkills = new ArrayList<NonactivateableSkill>();
		
		smasherNonActivateableSkills.add(new Observation());
		
		summonerNonActivateableSkills.add(new Observation());
		
		sneakNonActivateableSkills.add(new Observation());
		sneakNonActivateableSkills.add(new DetectTrap());
		
		Occupation smasherOccupation =  new Occupation( OccupationTypes.SMASHER, smasherStats, smasherEquipmentTypes, 
				smasherAllowableSkills, smasherActivateableSkills, smasherNonActivateableSkills);
		
		Occupation sneakOccupation = new Occupation( OccupationTypes.SNEAK, sneakStats, sneakEquipmentTypes, 
				sneakAllowableSkills, sneakActivateableSkills, sneakNonActivateableSkills);
		
		Occupation summonerOccupation = new Occupation( OccupationTypes.SUMMONER, summonerStats, summonerEquipmentTypes,
				summonerAllowableSkills, summonerActivateableSkills, summonerNonActivateableSkills);
		
		occupations.put("smasherOccupation", smasherOccupation);
		occupations.put("sneakOccupation", sneakOccupation);
		occupations.put("summonerOccupation", summonerOccupation);
	}
	
	public static Occupation getOccupation(String name)
	{
		return occupations.get(name);
	}
}